<!-- <template>
  <view class="history-item" @click="handleItemClick">
    <view class="item-header">
      <view class="interview-type">{{ data.type }}</view>
      <view class="score" :class="{ 'no-score': data.score === '--' }">
        得分: {{ data.score }}
      </view>
    </view>
    <view class="question-tag">问题: {{ data.question }}</view>
    <view class="time">{{ formatTime(data.createTime) }}</view>
  </view>
</template>

<script setup>
import { defineProps } from 'vue';

const props = defineProps({
  data: {
    type: Object,
    required: true,
    default: () => ({
      id: '',
      type: '未知类型',
      score: '--',
      question: '无题目信息',
      createTime: '',
      interviewId: ''
    })
  },
  showDetail: {
    type: Boolean,
    default: true
  }
});

const formatTime = (timestamp) => {
  if (!timestamp) return '未知时间';
  try {
    const date = new Date(timestamp);
    return `${date.getFullYear()}-${padZero(date.getMonth()+1)}-${padZero(date.getDate())} ${padZero(date.getHours())}:${padZero(date.getMinutes())}`;
  } catch (e) {
    console.warn('时间格式化错误:', e);
    return timestamp;
  }
};

const padZero = (num) => num.toString().padStart(2, '0');

const handleItemClick = () => {
  if (props.showDetail && props.data.interviewId) {
    uni.navigateTo({
      url: `/pages/report/InterviewReport?interviewId=${props.data.interviewId}`
    });
  }
};
</script>

<style scoped>
.history-item {
  background-color: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.interview-type {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.score {
  font-size: 14px;
  color: #1890ff;
  font-weight: 500;
}

.score.no-score {
  color: #999;
}

.question-tag {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
  line-height: 1.5;
  word-break: break-word;
}

.time {
  font-size: 12px;
  color: #999;
}
</style> -->